package B;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @Author czl
 * @Date 2024-03-20
 */
public class MainTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        SumThread sumThread = new SumThread(1,100);
        SumThread sumThread1 = new SumThread(101,900);
        SumThread sumThread2 = new SumThread(901,1000);

        FutureTask<Integer> futureTask = new FutureTask<>(sumThread);
        FutureTask<Integer> futureTask1 = new FutureTask<>(sumThread1);
        FutureTask<Integer> futureTask2 = new FutureTask<>(sumThread2);

        Thread thread = new Thread(futureTask);
        Thread thread1 = new Thread(futureTask1);
        Thread thread2 = new Thread(futureTask2);

        thread.start();
        thread1.start();
        thread2.start();

        int sum = futureTask.get()+futureTask1.get()+futureTask2.get();

        System.out.println(sum);
    }
}
